package  
{
	import org.flixel.*;
	/**
	 * ...
	 * @author morgan
	 */
	public class Particle extends FlxSprite
	{
		public var life:Number = 0;
		public function Particle() 
		{
			super(0, 0);
			exists = false;
		}
		
		public function spawn(x:int, y:int, image:Class, frameSize:int, frames:Array, time:Number, xv:Number = 0, yv:Number = 0, angles:int = 0):void
		{
			this.x = x;
			this.y = y;
			_animations = [];
			if (angles > 0)
			{
				this.loadRotatedGraphic(image, angles);
				angle = Math.random() * 360;
			}
			else
			{
				this.loadGraphic(image, true, false, frameSize, frameSize);
				this.addAnimation("default", frames, frames.length / time, false);
				play("default");
			}
			this.life = time;
			this.velocity.x = xv;
			this.velocity.y = yv;
			this.exists = true;
			this.x -= width / 2;
			this.y -= height / 2;
		}
		
		override public function update():void 
		{
			super.update();
			life -= FlxG.elapsed;
			if (life <= 0) { kill(); }
			velocity.x *= 0.97;
			velocity.y *= 0.97;
		}
	}

}